﻿using System;
using System.Text.RegularExpressions;

namespace MikeKappel.Com.CS
{
    /// <summary>
    /// Replace an Html tag attribute value
    /// </summary>
    public static partial class Helper
    {
        public static string HtmlTagAttributeReplace(String Source, String Tag, String Attribute, String replacementValue)
        {
            return Regex.Replace(Source, string.Format(@"(<{0}\b[^>]*?\b)({1})=""(?:[^""]*)""", Tag, Attribute), "$1$2=\"" + replacementValue + "\"");
        }
    }
}